﻿using BUS;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OnlineDigitalCameraWebsite
{
    public partial class Default : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadDuLieu();
            }
        }

        private void LoadDuLieu()
        {
            CameraBUS cB = new CameraBUS();
            ddlMayAnh.DataSource = cB.GetListTop10();
            ddlMayAnh.DataBind();
            AccessoriesBUS aB = new AccessoriesBUS();
            ddlPhuKien.DataSource = aB.GetListTop10();
            ddlPhuKien.DataBind();

            LensBUS lB = new LensBUS();
            ddlOnngKinh.DataSource = lB.GetListTop10();
            ddlOnngKinh.DataBind();

            ddlCameraContent.DataSource = cB.GetListAll();
            ddlCameraContent.DataBind();
        }

        protected void btnAddCart_Click(object sender, EventArgs e)
        {
            LinkButton bti = (LinkButton)sender;
            //string cate = Request.QueryString["cate"].ToString();
            string cate = "camera";
            //int id = int.Parse(Request.QueryString["id"].ToString());

              Label txtID = (Label)bti.Parent.FindControl("lblID");
              int id = int.Parse(txtID.Text);
            
            Image imghinh = (Image)bti.Parent.FindControl("imghinh");
            Session["lblimage"] = imghinh.ImageUrl;
            Response.Redirect("/ThemVaoGioHang.aspx?cate=" + cate + "&ID=" + id);
        }
    }
}